package empox.common;

import java.text.DecimalFormat;

public class EmpoxMath {

	public static double getDoubleByStr(String str) {
		double d = 0.00;

		try {
			d = Double.parseDouble(str);
		} catch (Exception ex) {
			d = 0.00;
		}
		return d;
	}

	public static float getFloatByStr(String str) {
		float f = 0;

		try {
			f = Float.parseFloat(str);
		} catch (Exception ex) {
			f = 0;
		}
		return f;
	}

	public static int getIntByStr(String str) {
		int i = 0;

		try {
			i = Integer.parseInt(str);
		} catch (Exception ex) {
			i = 0;
		}
		return i;
	}

	public static long getLongByStr(String str) {
		long i = 0;

		try {
			i = Long.parseLong(str);
		} catch (Exception ex) {
			i = 0;
		}
		return i;
	}

	public static String FormatStr(double d) {
		String temp = null;
		try {
			DecimalFormat df = new DecimalFormat("0.00");
			temp = df.format(d);
			return temp;
		} catch (Exception ex) {
			temp = "0.00";
		}
		return temp;
	}
}
